source /projects/tacoma6/workspace/xjsun/chip_top/innovus/scripts/RDL/proc_RDL.tcl
# ./RDL.conf.tcl
set tcl_precision 7

set METAL(AP,width) 12.0
set METAL(AP,space) 3.0
set SPACE_to_BUMP 4.0

set BUMP(H,space) 150.0
set BUMP(V,space) 75.0
set BUMP(size,width) 40.0

set bump_list [dbget selected]

foreach bump ${bump_list} {
    #set bump_center [lindex [dbget [dbget top.bumps.name $bump -p].bump_shape_center] 0]
    set bump_center [lindex [dbget $bump.bump_shape_center] 0]
    set bump_center_x [lindex $bump_center 0]
    set bump_center_y [lindex $bump_center 1]
    #set bump_net_name [dbget [dbget top.bumps.name $bump -p].net.name]
    set bump_net_name "VSS"
    # H wire
    set H_top_1_y [expr ${bump_center_y}+$BUMP(size,width)/2+${SPACE_to_BUMP}+$METAL(AP,width)/2]
    set H_top_1_x_1 [expr ${bump_center_x}-$BUMP(H,space)/2-$BUMP(size,width)/2]
    set H_top_1_x_2 [expr ${bump_center_x}+$BUMP(H,space)/2+$BUMP(size,width)/2]
    
    set H_bottom_1_y [expr ${bump_center_y}-$BUMP(size,width)/2-${SPACE_to_BUMP}-$METAL(AP,width)/2]
    set H_bottom_1_x_1 [expr ${bump_center_x}-$BUMP(H,space)/2-$BUMP(size,width)/2]
    set H_bottom_1_x_2 [expr ${bump_center_x}+$BUMP(H,space)/2+$BUMP(size,width)/2]

    set H_1_y [expr ${bump_center_y}+$METAL(AP,space)+$METAL(AP,width)]
    set H_1_x_1 [expr ${bump_center_x}-$BUMP(H,space)/2-$BUMP(size,width)/2]
    set H_1_x_2 [expr ${bump_center_x}+$BUMP(H,space)/2+$BUMP(size,width)/2]

    set H_2_y ${bump_center_y}
    set H_2_x_1 [expr ${bump_center_x}-$BUMP(H,space)/2-$BUMP(size,width)/2]
    set H_2_x_2 [expr ${bump_center_x}+$BUMP(H,space)/2+$BUMP(size,width)/2]

    set H_3_y [expr ${bump_center_y}-$METAL(AP,space)-$METAL(AP,width)]
    set H_3_x_1 [expr ${bump_center_x}-$BUMP(H,space)/2-$BUMP(size,width)/2]
    set H_3_x_2 [expr ${bump_center_x}+$BUMP(H,space)/2+$BUMP(size,width)/2]

    pr_auto_edit_wire AP ${bump_net_name} $METAL(AP,width) "{${H_top_1_x_1} ${H_top_1_y}} {${H_top_1_x_2} ${H_top_1_y}}"
    pr_auto_edit_wire AP ${bump_net_name} $METAL(AP,width) "{${H_bottom_1_x_1} ${H_bottom_1_y}} {${H_bottom_1_x_2} ${H_bottom_1_y}}"
    pr_auto_edit_wire AP ${bump_net_name} $METAL(AP,width) "{$H_1_x_1 $H_1_y} {$H_1_x_2 $H_1_y}"
    pr_auto_edit_wire AP ${bump_net_name} $METAL(AP,width) "{$H_2_x_1 $H_2_y} {$H_2_x_2 $H_2_y}"
    pr_auto_edit_wire AP ${bump_net_name} $METAL(AP,width) "{$H_3_x_1 $H_3_y} {$H_3_x_2 $H_3_y}"


    # V wire
    set V_1_x ${bump_center_x}
    set V_1_y_1 [expr ${bump_center_y}-$BUMP(size,width)/2-${SPACE_to_BUMP}-$METAL(AP,width)/2]
    set V_1_y_2 [expr ${bump_center_y}+$BUMP(size,width)/2+${SPACE_to_BUMP}+$METAL(AP,width)/2]
    
    set V_2_x [expr ${V_1_x}+$METAL(AP,width)+$METAL(AP,space)]
    set V_2_y_1 [expr ${bump_center_y}-$BUMP(size,width)/2-${SPACE_to_BUMP}-$METAL(AP,width)/2]
    set V_2_y_2 [expr ${bump_center_y}+$BUMP(size,width)/2+${SPACE_to_BUMP}+$METAL(AP,width)/2]
    set V_3_x [expr ${V_2_x}+$METAL(AP,width)+$METAL(AP,space)]
    set V_3_y_1 [expr ${bump_center_y}-$BUMP(size,width)/2-${SPACE_to_BUMP}-$METAL(AP,width)/2]
    set V_3_y_2 [expr ${bump_center_y}+$BUMP(size,width)/2+${SPACE_to_BUMP}+$METAL(AP,width)/2]
    set V_4_x [expr ${V_3_x}+$METAL(AP,width)+$METAL(AP,space)]
    set V_4_y_1 [expr ${bump_center_y}-$BUMP(size,width)/2-${SPACE_to_BUMP}-$METAL(AP,width)/2]
    set V_4_y_2 [expr ${bump_center_y}+$BUMP(size,width)/2+${SPACE_to_BUMP}+$METAL(AP,width)/2]
    set V_5_x [expr ${V_4_x}+$METAL(AP,width)+$METAL(AP,space)]
    set V_5_y_1 [expr ${bump_center_y}-$BUMP(size,width)/2-${SPACE_to_BUMP}-$METAL(AP,width)/2]
    set V_5_y_2 [expr ${bump_center_y}+$BUMP(size,width)/2+${SPACE_to_BUMP}+$METAL(AP,width)/2]

    
    set V_6_x [expr ${V_1_x}-$METAL(AP,width)-$METAL(AP,space)]
    set V_6_y_1 [expr ${bump_center_y}-$BUMP(size,width)/2-${SPACE_to_BUMP}-$METAL(AP,width)/2]
    set V_6_y_2 [expr ${bump_center_y}+$BUMP(size,width)/2+${SPACE_to_BUMP}+$METAL(AP,width)/2]
    set V_7_x [expr ${V_6_x}-$METAL(AP,width)-$METAL(AP,space)]
    set V_7_y_1 [expr ${bump_center_y}-$BUMP(size,width)/2-${SPACE_to_BUMP}-$METAL(AP,width)/2]
    set V_7_y_2 [expr ${bump_center_y}+$BUMP(size,width)/2+${SPACE_to_BUMP}+$METAL(AP,width)/2]
    set V_8_x [expr ${V_7_x}-$METAL(AP,width)-$METAL(AP,space)]
    set V_8_y_1 [expr ${bump_center_y}-$BUMP(size,width)/2-${SPACE_to_BUMP}-$METAL(AP,width)/2]
    set V_8_y_2 [expr ${bump_center_y}+$BUMP(size,width)/2+${SPACE_to_BUMP}+$METAL(AP,width)/2]
    set V_9_x [expr ${V_8_x}-$METAL(AP,width)-$METAL(AP,space)]
    set V_9_y_1 [expr ${bump_center_y}-$BUMP(size,width)/2-${SPACE_to_BUMP}-$METAL(AP,width)/2]
    set V_9_y_2 [expr ${bump_center_y}+$BUMP(size,width)/2+${SPACE_to_BUMP}+$METAL(AP,width)/2]

    pr_auto_edit_wire AP ${bump_net_name} $METAL(AP,width) "{$V_1_x $V_1_y_1} {$V_1_x $V_1_y_2}"
    pr_auto_edit_wire AP ${bump_net_name} $METAL(AP,width) "{$V_2_x $V_2_y_1} {$V_2_x $V_2_y_2}"
    pr_auto_edit_wire AP ${bump_net_name} $METAL(AP,width) "{$V_3_x $V_3_y_1} {$V_3_x $V_3_y_2}"
    pr_auto_edit_wire AP ${bump_net_name} $METAL(AP,width) "{$V_4_x $V_4_y_1} {$V_4_x $V_4_y_2}"
    pr_auto_edit_wire AP ${bump_net_name} $METAL(AP,width) "{$V_5_x $V_5_y_1} {$V_5_x $V_5_y_2}"
    pr_auto_edit_wire AP ${bump_net_name} $METAL(AP,width) "{$V_6_x $V_6_y_1} {$V_6_x $V_6_y_2}"
    pr_auto_edit_wire AP ${bump_net_name} $METAL(AP,width) "{$V_7_x $V_7_y_1} {$V_7_x $V_7_y_2}"
    pr_auto_edit_wire AP ${bump_net_name} $METAL(AP,width) "{$V_8_x $V_8_y_1} {$V_8_x $V_8_y_2}"
    pr_auto_edit_wire AP ${bump_net_name} $METAL(AP,width) "{$V_9_x $V_9_y_1} {$V_9_x $V_9_y_2}"
}